#pragma once
#ifndef BOUNDSCHECKING_H
#define BOUNDSCHECKING_H

namespace ssmt
{
	namespace boundschecking
	{
		class SimpleBoundsChecking
		{
		public:
			static const size_t SIZE_FRONT = 4;
			static const size_t SIZE_BACK = 4;

			static const unsigned int FRONT = 0xDEADBEEF;
			static const unsigned int BACK = 0xDEADBABE;

			inline void GuardFront(void* ptr) const 
			{
				int* m = static_cast<int*>(ptr);
				*m = FRONT;
				//std::memset(ptr,FRONT,SIZE_FRONT);
			}

			inline void GuardBack(void* ptr) const 
			{
				int* m = static_cast<int*>(ptr);
				*m = BACK;
				//std::memset(ptr,BACK,SIZE_BACK);
			}
 
			inline void CheckFront(void* ptr) const 
			{
				int* m = static_cast<int*>(ptr);
				if(*(m) != FRONT)
				{
					throw "Memory Coruption - FRONT";
				}
			}

			inline void CheckBack(void* ptr) const 
			{
				int* m = static_cast<int*>(ptr);
				if(*(m) != BACK)
				{
					throw "Memory Coruption - BACK";
				}
			}
		};

		class NoBoundsChecking
		{
		public:
			static const size_t SIZE_FRONT = 0;
			static const size_t SIZE_BACK = 0;
 
			inline void GuardFront(void*) const {}
			inline void GuardBack(void*) const {}
 
			inline void CheckFront(const void*) const {}
			inline void CheckBack(const void*) const {}
		};

	} //namespace boundschecking
} //namespace ssmt

#endif BOUNDSCHECKING_H